#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<stdio.h>
#include<unistd.h>
#include<string.h>


int main()
{
  printf("stdin: %d\n", stdin->_fileno);
  printf("stdout: %d\n", stdout->_fileno);
  printf("stderror: %d\n", stderr->_fileno);
  int fd =  open("log.txt", O_RDONLY); 
  if( fd < 0 ) 
  {
    perror("file failed to apply");
    return -1;
  }
  while(true)
  {
    char buffer[64];
    int n= read(fd, buffer, sizeof(buffer) - 1);
    if(n > 0)
    {
      buffer[n] = 0;
      printf("%s", buffer);
    }
    else if(n == 0)
    {
      break;
    }
  }
  //const char* msg = "hello world\n";
  //int cnt = 5;
  //while(cnt--)
  //{
  //  write(fd, msg, strlen(msg));
  //}
  //close(fd);
  return 0;
}
